package com.yyys.web.repository;

import com.yyys.web.entity.DRGoodsInfo;
import com.yyys.web.entity.GoodsInfo;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * Created by zhengsenwen on 2017/8/4.
 */

@Repository
public interface GoodsRepository extends JpaRepository<GoodsInfo, Serializable> {

    //user/dish/id
    @Query(value = "SELECT DISTINCT goodsTypeName FROM GoodsInfo WHERE ctid = ?1")
    List<String> findgoodsTypeNameById(String ctid);

    @Query(value = "SELECT goodsInfo FROM GoodsInfo goodsInfo WHERE goodsInfo.ctid = ?1 AND goodsInfo.goodsTypeName = ?2")
    List<GoodsInfo> findByCTIDAndGoodsTypeName(String ctid, String goodsTypeName);

    //user/list
//    @Query(value = "SELECT goodsInfo FROM GoodsInfo goodsInfo WHERE goodsInfo.ctid = ?1 AND goodsInfo.goodsTypeName = ?2")
//    List<GoodsInfo> findByCTIDAndGoodsTypeName();

    //user/test
    GoodsInfo findByGoodsId(String goodsId);

        //view/diningroom/{ctid}/goods/{goodsId}
    GoodsInfo findByCtidAndGoodsId(String ctid,String goodsId);


}